<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>微信小程序开发指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        
        .code-block {
            background: #2d3748;
            border-radius: 8px;
            overflow-x: auto;
        }
        
        .code-block pre {
            margin: 0;
            padding: 1rem;
            color: #e2e8f0;
            font-size: 0.875rem;
            line-height: 1.5;
        }
        
        .section-title {
            position: relative;
            display: inline-block;
        }
        
        .section-title::after {
            content: '';
            position: absolute;
            bottom: -8px;
            left: 0;
            width: 60px;
            height: 4px;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        
        .icon-box {
            width: 48px;
            height: 48px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 12px;
            color: white;
            font-size: 1.25rem;
        }
        
        .timeline-item {
            position: relative;
            padding-left: 2rem;
        }
        
        .timeline-item::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 2px;
            background: #e2e8f0;
        }
        
        .timeline-item::after {
            content: '';
            position: absolute;
            left: -4px;
            top: 1.5rem;
            width: 10px;
            height: 10px;
            background: #667eea;
            border-radius: 50%;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-5xl font-bold mb-6">微信小程序开发指南</h1>
                <p class="text-xl opacity-90 leading-relaxed">
                    从零开始掌握小程序开发，构建属于你的微信生态应用
                </p>
                <div class="mt-10 flex justify-center space-x-6">
                    <div class="flex items-center">
                        <i class="fas fa-code mr-2"></i>
                        <span>完整代码示例</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-mobile-alt mr-2"></i>
                        <span>实战开发技巧</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-rocket mr-2"></i>
                        <span>快速上手指南</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- 常见问题解决 -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-xl p-8 card-hover">
                <div class="flex items-center mb-6">
                    <div class="icon-box mr-4">
                        <i class="fas fa-exclamation-triangle"></i>
                    </div>
                    <h2 class="text-3xl font-bold section-title">常见问题解决</h2>
                </div>
                
                <div class="bg-red-50 border-l-4 border-red-500 p-6 rounded-lg">
                    <h3 class="text-xl font-semibold text-red-800 mb-3">
                        <i class="fas fa-bug mr-2"></i>自定义页面不加载问题
                    </h3>
                    <p class="text-gray-700 mb-4">当创建新页面后发现页面无法正常加载时，需要在对应的 .js 文件中进行初始化：</p>
                    <div class="code-block">
                        <pre>// 在 xxx.js 中添加
Page({})</pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- 小程序架构概览 -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-xl p-8">
                <div class="flex items-center mb-8">
                    <div class="icon-box mr-4">
                        <i class="fas fa-sitemap"></i>
                    </div>
                    <h2 class="text-3xl font-bold section-title">小程序架构概览</h2>
                </div>

                <div class="mermaid">
                    <div class="mermaid">
graph TD
    A[小程序项目结构] --> B[JSON配置]
    A --> C[WXML模板]
    A --> D[WXSS样式]
    A --> E[JS逻辑]
    
    B --> B1[app.json全局配置]
    B --> B2[page.json页面配置]
    
    C --> C1[数据绑定]
    C --> C2[条件渲染]
    C --> C3[列表渲染]
    
    D --> D1[样式规则]
    D --> D2[尺寸单位rpx]
    
    E --> E1[生命周期]
    E --> E2[事件处理]
    E --> E3[数据管理]
                    </div>
                </div>

                <div class="grid md:grid-cols-2 gap-6 mt-8">
                    <div class="bg-gradient-to-br from-purple-50 to-pink-50 p-6 rounded-xl">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-file-code mr-2 text-purple-600"></i>
                            JSON 配置文件
                        </h3>
                        <p class="text-gray-700">负责小程序的静态配置，包括页面路径、窗口样式、标签栏等全局和页面级别的设置。</p>
                    </div>
                    
                    <div class="bg-gradient-to-br from-blue-50 to-cyan-50 p-6 rounded-xl">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-code mr-2 text-blue-600"></i>
                            WXML 模板
                        </h3>
                        <p class="text-gray-700">类似于 HTML，用于描述页面结构，支持数据绑定、条件渲染、列表渲染等特性。</p>
                    </div>
                    
                    <div class="bg-gradient-to-br from-green-50 to-emerald-50 p-6 rounded-xl">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-palette mr-2 text-green-600"></i>
                            WXSS 样式
                        </h3>
                        <p class="text-gray-700">基于 CSS 扩展，支持 rpx 响应式单位，用于控制组件的视觉表现。</p>
                    </div>
                    
                    <div class="bg-gradient-to-br from-orange-50 to-yellow-50 p-6 rounded-xl">
                        <h3 class="text-xl font-semibold mb-3 flex items-center">
                            <i class="fas fa-cogs mr-2 text-orange-600"></i>
                            JS 逻辑交互
                        </h3>
                        <p class="text-gray-700">处理用户交互、管理页面数据、调用小程序 API，实现业务逻辑。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- 创建自定义页面 -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-xl p-8">
                <div class="flex items-center mb-8">
                    <div class="icon-box mr-4">
                        <i class="fas fa-file-alt"></i>
                    </div>
                    <h2 class="text-3xl font-bold section-title">创建自定义页面</h2>
                </div>

                <div class="space-y-6">
                    <div class="timeline-item">
                        <h3 class="text-lg font-semibold mb-2">1. 创建页面文件结构</h3>
                        <p class="text-gray-700 mb-3">在 pages 目录下创建新文件夹，包含四个同名文件：</p>
                        <div class="bg-gray-50 p-4 rounded-lg font-mono text-sm">
                            <div>pages/</div>
                            <div class="ml-4">└── user/</div>
                            <div class="ml-8">├── user.js</div>
                            <div class="ml-8">├── user.json</div>
                            <div class="ml-8">├── user.wxml</div>
                            <div class="ml-8">└── user.wxss</div>
                        </div>
                    </div>

                    <div class="timeline-item">
                        <h3 class="text-lg font-semibold mb-2">2. 编写页面内容</h3>
                        <div class="code-block mb-4">
                            <pre>// user.wxml
&lt;text&gt;Hello WeChat&lt;/text&gt;</pre>
                        </div>
                        <div class="code-block mb-4">
                            <pre>// user.js
Page({})</pre>
                        </div>
                        <div class="code-block">
                            <pre>// user.json
{
  "navigationBarTitleText": "用户页面"
}</pre>
                        </div>
                    </div>

                    <div class="timeline-item">
                        <h3 class="text-lg font-semibold mb-2">3. 配置页面路径</h3>
                        <p class="text-gray-700 mb-3">在 app.json 中添加页面路径：</p>
                        <div class="code-block">
                            <pre>{
  "pages": [
    "pages/user/user",
    "pages/index/index"
  ]
}</pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- 生命周期详解 -->
        <section class="mb-16">
            <div class="bg-white rounded-2xl shadow-xl p-8">
                <div class="flex items-center mb-8">
                    <div class="icon-box mr-4">
                        <i class="fas fa-sync-alt"></i>
                    </div>
                    <h2 class="text-3xl font-bold section-title">生命周期详解</h2>
                </div>

                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-xl font-semibold mb-4 text-purple-700">
                            <i class="fas fa-mobile-alt mr-2"></i>应用生命周期
                        </h3>
                        <div class="space-y-4">
                            <div class="bg-purple-50 p-4 rounded-lg">
                                <h4 class="font-semibold text-purple-800">onLaunch</h4>
                                <p class="text-sm text-gray-700 mt-1">小程序初始化完成时触发，全局只触发一次</p>
                            </div>
                            <div class="bg-purple-50 p-4 rounded-lg">
                                <h4 class="font-semibold text-purple-800">onShow</h4>
                                <p class="text-sm text-gray-700 mt-1">小程序启动或从后台进入前台时触发</p>
                            </div>
                            <div class="bg-purple-50 p-4 rounded-lg">
                                <h4 class="font-semibold text-purple-800">onHide</h4>
                                <p class="text-sm text-gray-700 mt-1">小程序从前台进入后台时触发</p>
                            </div>
                            <div class="bg-purple-50 p-4 rounded-lg">
                                <h4 class="font-semibold text-purple-800">onError</h4>
                                <p class="text-sm text-gray-700 mt-1">小程序发生脚本错误或 API 调用失败时触发</p>
                            </div>
                        </div>
                    </div>

                    <div